/*
 * Powered By dico
 * Since 2017 - 2018
 */package com.seeyoui.kensite.bussiness.orderlang.warehouse.service;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.seeyoui.kensite.common.base.service.BaseService;

import java.util.*;

import com.seeyoui.kensite.common.base.domain.EasyUIDataGrid;
import com.seeyoui.kensite.common.base.service.BaseService;
import com.seeyoui.kensite.common.exception.CRUDException;
import com.seeyoui.kensite.common.util.*;
import com.seeyoui.kensite.common.constants.StringConstant;
import com.seeyoui.kensite.bussiness.orderlang.warehouse.domain.Warehouse;
import com.seeyoui.kensite.bussiness.orderlang.warehouse.persistence.WarehouseMapper;

/**
 * Warehouse
 * @author dico
 * @version 2.0
 * @since 1.0
 * @date 2018-02-07
 */

@Service
public class WarehouseService extends BaseService {
	
	@Autowired
	private WarehouseMapper warehouseMapper;

	/**
	 * 根据ID查询单条数据
	 * @param id
	 * @return
	 * @throws CRUDException
	 */
	public Warehouse findOne(String id) throws CRUDException{
		return warehouseMapper.findOne(id);
	}
	
	/**
	 * 查询数据集合
	 * @param warehouse
	 * @return
	 * @throws CRUDException
	 */
	public List<Warehouse> findList(Warehouse warehouse) throws CRUDException {
		return warehouseMapper.findList(warehouse);
	}
	
	/**
	 * 查询所有数据集合
	 * @param warehouse
	 * @return
	 * @throws CRUDException
	 */
	public List<Warehouse> findAll(Warehouse warehouse) throws CRUDException {
		return warehouseMapper.findAll(warehouse);
	}
	
	/**
	 * 查询数据总数
	 * @param warehouse
	 * @return
	 * @throws CRUDException
	 */
	public int findTotal(Warehouse warehouse) throws CRUDException {
		return warehouseMapper.findTotal(warehouse);
	}
	
	/**
	 * 查询数据总数排除当前数据
	 * @param warehouse
	 * @return
	 * @throws CRUDException
	 */
	public int findExTotal(Warehouse warehouse) throws CRUDException {
		return warehouseMapper.findExTotal(warehouse);
	}
	
	/**
	 * 数据新增
	 * @param warehouse
	 * @throws CRUDException
	 */
	public void save(Warehouse warehouse) throws CRUDException{
		warehouse.preInsert();
		warehouseMapper.save(warehouse);
	}
	
	/**
	 * 数据修改
	 * @param warehouse
	 * @throws CRUDException
	 */
	public void update(Warehouse warehouse) throws CRUDException{
		warehouse.preUpdate();
		warehouseMapper.update(warehouse);			
	}
	
	/**
     * 数据修改
     * @param warehouse
     * @throws CRUDException
     */
    public void saveOrUpdate(Warehouse warehouse) throws CRUDException{
        if(!StringUtils.isEmpty(warehouse.getId())){
            update(warehouse);         
        }else{
            save(warehouse);
        }
    }
	
	/**
	 * 数据删除
	 * @param listId
	 * @throws CRUDException
	 */
	public void delete(List<String> listId) throws CRUDException {
		warehouseMapper.delete(listId);
	}
	
	/**
	 * 数据假删除
	 * @param warehouse
	 * @throws CRUDException
	 */
	public void remove(Warehouse warehouse) throws CRUDException{
		warehouse.preUpdate();
		warehouseMapper.remove(warehouse);			
	}
	
}